.TH std::ranges::elements_view::iterator::operator* 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::ranges::elements_view::iterator::operator* \- std::ranges::elements_view::iterator::operator*

.SH Synopsis
   constexpr decltype(auto) operator*() const;  \fI(since C++20)\fP

   Returns the element into V the underlying iterator points to.

   Effectively returns /*get-element*/(this->base()), where for an expression e,
   /*get-element*/(e) is

     * std::get<N>(*e), if ranges::range_reference_t<Base> is a reference type.
       Otherwise,
     * static_cast<E>(std::get<N>(*e)), where E is
       std::remove_cv_t<std::tuple_element_t<N, ranges::range_reference_t<Base>>>.

.SH Parameters

   \fI(none)\fP

.SH Return value

   The current element.

.SH Notes

   operator-> is not provided.

.SH Example


// Run this code

 #include <iostream>
 #include <ranges>
 #include <string_view>
 #include <tuple>

 int main()
 {
     using T = std::tuple<int, char, std::string_view>;

     const auto il = {
         T{1, 'A', "α"},
         T{2, 'B', "β"},
         T{3, 'C', "γ"},
     };

     const auto view {il | std::views::elements<2>};

     const auto iter {view.begin() + 1};

     std::cout << *iter << '\\n';
 }

.SH Output:

 β

.SH See also

   operator[] accesses an element by index
   (C++20)    \fI(public member function)\fP
